package com.itheima.leyou.client;

import com.itheima.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@FeignClient("item-service")
public interface ItemFeignClient {

    /**
     * 分页查询商品信息
     * @param page
     * @param rows
     * @param saleable
     * @param brandId
     * @param categoryId
     * @param id
     * @return
     */
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> queryPage(
            @RequestParam(value = "page",defaultValue = "1")Integer page,
            @RequestParam(value = "rows",defaultValue = "10")Integer rows,
            @RequestParam(value = "saleable",required = false)Boolean saleable,
            @RequestParam(value = "brandId",required = false)Long brandId,
            @RequestParam(value = "categoryId",required = false)Long categoryId,
            @RequestParam(value = "id",required = false)Long id);


    /**
     * 根据spuID查询sku的集合
     * @param id
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuByspuId(
            @RequestParam("id")Long id);


    /**
     * 根据商品id（spuId）查询对应的规格参数组集合以及组内参数的信息，及对应值
     * @param spuId
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> listSpec(
            @RequestParam("id")Long spuId,
            @RequestParam(value = "searching",required = false)Boolean searching);


    /**
     * 根据品牌id查询所对应的品牌信息
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandById(@RequestParam("ids") List<Long> ids);


    /**
     * 根据品牌id查询所对应的品牌信息
     * @param id
     * @return
     */
    @GetMapping("/brand/{id}")
   BrandDTO queryBrandById(@PathVariable("id")Long id);

    /**
     * 根据分类ids集合查询分类集合信息
     * @param ids
     * @return
     */
    //queryCategoryByIds
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("ids")List<Long> ids);



    /**
     * 根据id查询商品
     * @param id
     * @return
     */
    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(
            @PathVariable("id")Long id);


    /**
     * 根据id查询商品详情
     * @param sid
     * @return
     */
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO queryDetailById(
            @RequestParam("id")Long sid);


    /**
     * 根据分类id查询规格组及组内参数
     * @param categoryId
     * @return
     */
    @GetMapping("/spec/list")
    List<SpecGroupDTO> listSpecGroup(
            @RequestParam("id")Long categoryId);
}
